package com.cyandpos.pad.pay.adapter;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cyandpos.pad.R;
import com.cyandpos.pad.common.commondata.ErpCommonData;
import com.cyandpos.pad.posdata.Payment;

import java.util.ArrayList;
import java.util.List;

public class RefundPayListAdapter extends BaseAdapter {
    private Context context;
    private List<Payment> fkfs = new ArrayList<Payment>();

    public RefundPayListAdapter(Context context, List<Payment> mfkfs) {
        this.context = context;
        this.fkfs = mfkfs;

    }

    @Override
    public int getCount() {
        return fkfs.size();
    }

    @Override
    public Object getItem(int position) {
        return fkfs.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate
                    (R.layout.refund_pay_list_item, parent, false);
        }
        TextView tv_name = BaseViewHolder.get(convertView, R.id.pay_name);
        TextView tv_money = BaseViewHolder.get(convertView, R.id.pay_name_money);
        if(fkfs.get(position).getPayName().length()>4 ){
            tv_name.setText(fkfs.get(position).getPayName().substring(0,4)+"……");
        }else{
            tv_name.setText(fkfs.get(position).getPayName());
        }
        tv_money.setText(fkfs.get(position).getPayAmount()+"");

        return convertView;
    }

    public void updateData(List<Payment> mList){
        fkfs=mList;
        notifyDataSetChanged();
    }
}
